﻿<?php
session_start();

if(isset($_SESSION['loggedIn'])) {
	$loggedIn = true;
}
else {
	$loggedIn = false;
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Lightcontrol</title>

    <!-- Bootstrap libraries -->
    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    
	<!-- Custom styles for this template -->
   
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

    <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="index.php">Lightcontrol</a>
        </div>
        <div class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            <li class="active"><a id="index" href="index.php">Home</a></li>
             <li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown">Electronics<b class="caret"></b></a>
				<ul class="dropdown-menu">
					<li><a id="buildings" href="buildings.php">Geb&auml;ude</a></li>
					<li><a id="rooms" href="rooms.php">R&auml;ume</a></li>
					<li><a id="plugs" href="plugs.php">Steckdosen</a></li>
				</ul>
			</li>
            <li><a id="contact" href="contact.php">Kontakt</a></li>
          </ul>
		  <ul class="nav navbar-nav navbar-right">
				<?php if($loggedIn) { ?>
					<li><p class="navbar-text"><?php echo "Logged in as ".$_SESSION['username']; ?> </p></li>
					<li><a id="logout" href="logout.php">Logout</a></li>
				<?php } else { ?>
					<li><a id="login" href="login.php">Login</a></li>
				<?php } ?>
				
		   </ul>
        </div><!--/.nav-collapse -->
      </div>
	</div>
    <div class="container" style="margin-top:50px">
      <div class="starter-template">
        <h1>Home</h1>
        <?php if($loggedIn) {
				echo "<p class=\"lead\">Welcome ".$_SESSION['username'].".</p>"; ?>
				<ul>
					<li><a href="./buildings.php">Geb&auml;ude</a></li>
					<li><a href="./rooms.php">R&auml;ume</a></li>
					<li><a href="./plugs.php">Steckdose</a></li>
				</ul>
		<?php } else { ?>
			<a href="./login.php">Login</a>
		<?php } ?>
      </div>
    </div><!-- /.container -->
  </body>
  <script>
	$( document ).ready(function() {
		generateDiagramm();
	});
	
	function generateDiagramm(){
		var graph = new joint.dia.Graph;

		var paper = new joint.dia.Paper({
			el: $('#diagramm'),
			width: 800,
			height: 600,
			gridSize: 1,
			model: graph
		});
	}
  </script>
</html>
